import request from '@/utils/request'

/**
 * 获取团队等级列表
 * @param params
 * @returns
 */
export function getFenxiaoLevelList(params: Record<string, any>) {
    return request.get(`shop_fenxiao/fenxiao_level`, { params })
}

/**
 * 获取团队等级详情
 * @param level_id 团队等级level_id
 * @returns
 */
export function getFenxiaoLevelInfo(level_id: number) {
    return request.get(`shop_fenxiao/fenxiao_level/${ level_id }`);
}

/**
 * 获取团队等级权重
 */
export function getFenxiaoLevelNum() {
    return request.get('shop_fenxiao/fenxiao_level_num');
}

/**
 * 获取团队等级升级条件卡片
 */
export function getFenxiaoLevelCard(params: Record<string, any>) {
    return request.get('shop_fenxiao/fenxiao_level_card', { params });
}

/**
 * 添加团队等级
 * @param params
 * @returns
 */
export function addFenxiaoLevel(params: Record<string, any>) {
    return request.post('shop_fenxiao/fenxiao_level', params, { showErrorMessage: true, showSuccessMessage: true })
}

/**
 * 编辑团队等级
 * @param params
 * @returns
 */
export function editFenxiaoLevel(params: Record<string, any>) {
    return request.put(`shop_fenxiao/fenxiao_level/${ params.id }`, params, {
        showErrorMessage: true,
        showSuccessMessage: true
    })
}

/**
 * 删除团队等级
 * @param id
 * @returns
 */
export function deleteFenxiaoLevel(id: number) {
    return request.delete(`shop_fenxiao/fenxiao_level/${ id }`, { showErrorMessage: true, showSuccessMessage: true })
}

/**
 * 获取会员列表(有分页)
 */
export function getFenxiaoPage(params: Record<string, any>) {
    return request.get('/member/member/team_lists', { params });
}
/**
 * 编辑会员
 * @param params
 * @returns
 */
export function editFengxiao(params: Record<string, any>) {
    return request.put(`member/member/parent/${ params.id }`, params, {
        showErrorMessage: true,
        showSuccessMessage: true
    })
}

/**
 * 获取会员申请状态
 */
export function getFenxiaoApplayStatus() {
    return request.get('shop_fenxiao/fenxiao_apply_status');
}

/**
 * 获取会员列表(用于弹框选择)（有分页）
 */
export function getSelectFenxiaoList(params: Record<string, any>) {
    return request.get('member/member/member_of_select', { params });
}

/**
 * 获取团队列表
 * @param params
 */
export function getFenxiaoTeam(params: Record<string, any>) {
    return request.get(`/member/member/team`, { params });
}
/**
 * 获取会员详情
 * @param id
 * @returns
 */
export function getFenxiaoInfo(id: number) {
    return request.get(`/member/member/team/${ id }`);
}

/**
 * 获取团队佣金账户明细
 * @param params
 */
export function getFenxiaoAccount(params: Record<string, any>) {
    return request.get(`shop_fenxiao/fenxiao/account/${ params.id }`, { params });
}

/**
 * 获取团队海报设置
 */
export function getRangePosterConfig() {
    return request.get('distributor/poster');
}

/**
 * 编辑团队海报设置
 * @param params
 * @returns
 */
export function setRangePosterConfig(params: Record<string, any>) {
    return request.put('distributor/poster', params, {
        showErrorMessage: true,
        showSuccessMessage: true
    })
}

/**
 * 获取团队订单列表
 * @param params
 * @returns
 * */
export function getTeamOrderList(params: Record<string, any>) {
    return request.get('distributor/team/list', { params })
}

/**
 * 获取团队业绩列表
 * @param params
 * @returns
 */
export function getTeamPerformance(id?: number, params?: Record<string, any>) {
    return request.get(`/member/member_performance/${ id }`, { params })
}